
#ifndef IAP2INTERFACE_H
#define IAP2INTERFACE_H

#ifdef  __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdint.h>
#include <libusb.h>

#include "DebugServices.h"

#define kiAP2TransportType_Unknown      0
#define kiAP2TransportType_HostUsb      1
#define kiAP2TransportType_DeviceUsb    2
#define kiAP2TransportType_Bluetooth    3
#define kiAP2TransportType_WiFi         4

extern int  giAP2TransportType;
extern char gDeviceId[ 18 ];        // deviceID of the device.
extern int  gWireConflictWireless;

//===========================================================================================================================
//  CarPlay2iAP2InterfaceDelegate
//===========================================================================================================================

typedef void (*CarPlay2iAP2InterfaceCarPlayStartBonjour_f)();
typedef void (*CarPlay2iAP2InterfaceSendiAPMessage_f)(int length, const unsigned char* ptr);
typedef int (*CarPlay2iAP2InterfaceStartAirPlayServer_f)();
typedef void (*CarPlay2iAP2InterfaceStopAirPlayServer_f)();
typedef int (*CarPlay2iAP2InterfaceCarPlayControllerContainsCString_f)(const char* inDeviceID);
typedef int (*CarPlay2iAP2InterfaceCarPlayControllerEqual_f)();
typedef void (*CarPlay2iAP2InterfaceEnd_f)();

typedef struct {
    CarPlay2iAP2InterfaceCarPlayStartBonjour_f  carPlayStartBonjour_f;
    CarPlay2iAP2InterfaceSendiAPMessage_f       sendiAPMessage_f;
    CarPlay2iAP2InterfaceEnd_f                  end_f;
    CarPlay2iAP2InterfaceStartAirPlayServer_f   startAirPlayServer_f;
    CarPlay2iAP2InterfaceStopAirPlayServer_f    stopAirPlayServer_f;
    CarPlay2iAP2InterfaceCarPlayControllerContainsCString_f     controllerContainsCString_f;
    CarPlay2iAP2InterfaceCarPlayControllerEqual_f               controllerEqual_f;

} CarPlay2iAP2InterfaceDelegate;

#define CarPlay2iAP2InterfaceDelegateInit( PTR )    memset( (PTR), 0, sizeof( CarPlay2iAP2InterfaceDelegate ) );

void CarPlay2iAP2InterfaceSetDelegate(const CarPlay2iAP2InterfaceDelegate* inDelegate);

void    iAP2InterfaceInitial();
void    BonjourCarPlayAvailability();
int     _getBluetoothAddress(char* outAddress);
void    _sendWiFiData(const char* ptr, int length);
void    iAP2OverCarPlaySetup();

void    AirPlaySessionCreated();
void    AirPlaySessionFinalized();

void    AirPlaySessionControlDisableBluetooth();
int     startCarplay(int argc, char** argv);
int    setPlatformParam(int argc, char** argv);


OSStatus _GetUsbRoleStatus(char* outRoleStatus);

#ifdef  __cplusplus
}
#endif
#endif //IAP2INTERFACE_H
